package Operation;

import Book.Book;
import Book.BookList;

import java.util.Scanner;

public class ReturnOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");
        System.out.println("输入你想要归还图书的名字");
        Scanner in = new Scanner(System.in);
        String name = in.nextLine();
        for (int i = 0; i < bookList.getBookSize(); i++) {
            Book book = bookList.getBook(i);
            if (book.getName().equals(name) && book.isBorrowde()) {
                book.setBorrowde(false);
                System.out.println("归还成功");
            }else if(book.getName().equals(name) && !(book.isBorrowde())) {
                System.out.println("该书未借出");
            }
        }
    }
}
